package com.frank.service.impl;

import com.frank.dao.ResumeMapper;
import com.frank.model.Resume;
import com.frank.model.ResumeCriteria;
import com.frank.service.ResumeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ResumeServiceImpl implements ResumeService {

    @Resource
    private ResumeMapper resumeMapper;

    @Override
    public Resume getResumeByUserId(Integer userId) {
        ResumeCriteria resumeCriteria = new ResumeCriteria();
        resumeCriteria.createCriteria().andUserIdEqualTo(userId);
        List<Resume> resumeList = resumeMapper.selectByExample(resumeCriteria);
        return resumeList.get(0);
    }

    @Override
    public List<Resume> getResumeListByInterviewId(Integer interviewId) {
        return resumeMapper.selectByInterviewId(interviewId);
    }

    @Override
    public List<Resume> getResumeListByRecruitType(String recruitType) {
        return resumeMapper.selectByRecruitType(recruitType);
    }

    @Override
    public boolean updateResume(Resume resume) {
        return resumeMapper.updateByPrimaryKeySelective(resume) == 1;
    }

    @Override
    public boolean insertResume(Resume resume) {
        return resumeMapper.insertSelective(resume) == 1;
    }
}
